package com.hollycrm.hollysqm.job.index.dao;

import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import com.hollycrm.hollysqm.entities.TblJobIndex;

/**
 * 查询job索引表信息
 * @author jianglong
 * @date 2017年2月27日 上午10:29:33
 */
public interface IndexJobDao extends CrudRepository<TblJobIndex, String> {
		
	/**
	 * 更新job索引表的状态和次数
	 * @param status
	 * @param clrcle
	 * @return
	 */
	@Transactional
    @Modifying
    @Query("update TblJobIndex t set t.exeTime =:exeTime , t.status = '1' , t.circle = :circle where t.jobName=:jobName")
    public int updateJobIndex(@Param("exeTime") String exeTime, @Param("circle") int circle,@Param("jobName") String jobName);
	
	/**
	 * 更新job索引表的状态为执行中
	 * @param status
	 * @param clrcle
	 * @return
	 */
	@Transactional
    @Modifying
    @Query("update TblJobIndex t set t.status = '0' where t.jobName=:jobName")
    public int updateJobStatus(@Param("jobName") String jobName);

	/**
	 * 查询job索引表记录
	 * @return
	 */
    @Query("select t from TblJobIndex t where t.jobName=:jobName")
    public List<TblJobIndex> getJobIndexList(@Param("jobName") String jobName);
	
}
